/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.dahg.project.istu.web.menu;

import com.dahg.project.istu.controller.bean.menu.IMenuService;
import com.dahg.project.istu.web.commons.UsuarioBean;
import com.dahg.project.istu.web.commons.abstracto.AbstractManagedBean;
import javax.annotation.PostConstruct;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.ViewScoped;
import org.primefaces.model.menu.MenuModel;

/**
 *
 * @author dahg
 */
@ManagedBean
@ViewScoped
public class MenuBean extends AbstractManagedBean {
    
    private MenuModel model;
    @ManagedProperty("#{usuarioBean}")
    private UsuarioBean usuarioBean;
    @EJB
    private IMenuService service;
    
    @PostConstruct
    public void init() {
        MenuFactory factory = new MenuFactory();
        model = factory.getModel(usuarioBean.getCurrent().getRol(),service);
    }

    public MenuModel getModel() {
        return model;
    }

    public void setModel(MenuModel model) {
        this.model = model;
    }

    public void setUsuarioBean(UsuarioBean usuarioBean) {
        this.usuarioBean = usuarioBean;
    }
    
    
}
